/**
 * jims
 */
package com.jims.master.modules.doctor.service;

import com.jims.master.common.persistence.Page;
import com.jims.master.common.service.TreeService;
import com.jims.master.common.web.impl.BaseDto;
import com.jims.master.modules.doctor.dao.HisDiagnosisDao;
import com.jims.master.modules.doctor.entity.HisDiagnosis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 诊断Service
 * @author chenxy
 * @version 2017-03-06
 */
@Service
@Transactional(readOnly = true)
public class HisDiagnosisService extends TreeService<HisDiagnosisDao, HisDiagnosis> {
	@Autowired
	private HisDiagnosisDao hisDiagnosisDao;

	public HisDiagnosis get(String id) {
		return super.get(id);
	}
	
	public List<HisDiagnosis> findList(HisDiagnosis hisDiagnosis) {
		return super.findList(hisDiagnosis);
	}
	
	public Page<HisDiagnosis> findPage(Page<HisDiagnosis> page, HisDiagnosis hisDiagnosis) {
		return super.findPage(page, hisDiagnosis);
	}
	
	@Transactional(readOnly = false)
	public int save(HisDiagnosis hisDiagnosis) {
		if(!"".equals(hisDiagnosis.getVisitId()) && hisDiagnosis.getVisitId() != null){
			hisDiagnosis.setClinicId("");
		}else {
			hisDiagnosis.setInoroutFlag("0");
			hisDiagnosis.setVisitId("");
		}
		return super.save(hisDiagnosis);
	}
	
	@Transactional(readOnly = false)
	public int delete(HisDiagnosis hisDiagnosis) {
		return super.delete(hisDiagnosis);
	}

	/**
	 * 诊断列表
	 * @param clinicId
	 * @author 陈涛
	 * @return
	 */
	public List<HisDiagnosis> getByClinicId(String clinicId,String patientId){
		return hisDiagnosisDao.getByInoroutId(clinicId,patientId);
	}

	/**
	 * emr-诊断接口
	 * @param patientId
	 * @param visitId
	 * @return
	 * @author 赵宁
	 */
	public List<BaseDto> findDiagnosisEmr(String patientId,String visitId){
		return hisDiagnosisDao.findDiagnosisEmr(patientId,visitId);

 	}
}